Skip to content

@W-19143871 Marketing Consent Footer Email Capture component with Shopper Consents hooks#3674

Merged
mitesh-patel-crm merged 9 commits intodevelopfrom
mitesh-patel-crm/develop-shopper-consent-marketing-preferences-signed
Feb 24, 2026
Merged

@W-19143871 Marketing Consent Footer Email Capture component with Shopper Consents hooks#3674
mitesh-patel-crm merged 9 commits intodevelopfrom
mitesh-patel-crm/develop-shopper-consent-marketing-preferences-signed

Conversation

@mitesh-patel-crm
Copy link
Collaborator

@mitesh-patel-crm mitesh-patel-crm commented Feb 19, 2026

This feature is to add support for shopper subscriptions to marketing communications. An example is included as the email subscription component in the footer section.

Description

The feature uses the Shopper Consents API to opt shoppers into consent subscriptions configured by an administrator in B2C Commerce.

Requires the EnableConsentWithMarketingCloud Shopper Configurations flag is set (meaning the feature is enabled in ECOM).

SLAS Client requires the scope sfcc.shopper-consents to read consent options, and sfcc.shopper-consents.rw to submit consent (opt-in or opt-out).

As an example, the SubscribeMarketingConsent footer component uses the useMarketingConsent hook for managing consent data and mutations via useEmailSubscription to help manage email subscriptions. This example footer component will not attempt any callouts if the feature is disabled (as indicated by the EnableConsentWithMarketingCloud Shopper Configurations flag).

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Changes

  • Updated Email Subscription component (in the footer section) with Shopper Consents hooks, also with updated styling and labels.
  • Updated commerce-sdk-react to use Shopper Consents hooks.
  • Fix for email validation on marketing consent capture: TLD must be more than 1 character.
  • Increase package max size from 90KB to 95KB, accounting for footer component size.
  • Check for feature enablement via Shopper Configurations API (feature=>EnableConsentWithMarketingCloud)

How to Test-Drive This PR

  • Enable Salesforce Connections in your B2C Commerce instance to connect with a Salesforce Org that has Data Cloud and E360 Engagement Channels enabled.
  • Set up Marketing Consent in B2C Commerce
  • Try email footer component to capture shopper marketing consent.

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

Screenshots:

  • Success
  • email_sub_iPhone_success
  • Error
  • email_sub_iPhone_error

@mitesh-patel-crm mitesh-patel-crm requested a review from a team as a code owner February 19, 2026 06:21
@cc-prodsec
Copy link
Collaborator

cc-prodsec commented Feb 19, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

…mmunications. Email capture component updated in footer section to use Shopper Consents API. [#3674]
[formatMessage]
)

const handleSignUp = useCallback(async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can a user click on the signup button multiple times to create duplicate submissions or race conditions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would be handled gracefully in the ECOM back-end, by nature of relying on the ECOM DB to persist the opt-in/opt-out preference for the user, in the order the request were received. The last one received will overwrite any prior ones.

* Regular expression for email validation
* Validates standard email format with domain and TLD
*/
export const EMAIL_REGEX = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*\.[a-zA-Z]{2,}$/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reuse the logic in email-utils.js?

* @param {string} phone - The phone number to validate
* @returns {ValidationResult} Validation result with error code if invalid
*/
export const validatePhone = (phone) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually used anywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope! But I wanted to leave tests and validations for completeness on the API, as trying to interact with various Consents APIs (even ones we don't demonstrate in the example) require a particular E164 format for phone numbers.

{state?.feedback?.message && (
<Alert status={state.feedback.type === 'error' ? 'error' : 'success'} mb={4}>
<AlertIcon />
<AlertDescription>{state.feedback.message}</AlertDescription>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the UX calling for inline alert instead of toast?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Perhaps a Toast could work, but it would show at the top of the app. I forget the UX reasons for making it inline. I can ask if they recall.

…mail subscription hooks to follow react-hook-form pattern. Consolidated email and phone number validations to common util.
kzheng-sfdc
kzheng-sfdc previously approved these changes Feb 21, 2026
bfeister
bfeister previously approved these changes Feb 24, 2026
@mitesh-patel-crm mitesh-patel-crm added the skip changelog Skip the "Changelog Check" GitHub Actions step even if the Changelog.md files are not updated label Feb 24, 2026
…or footer component size. Made a11y improvements to contrast.
@mitesh-patel-crm mitesh-patel-crm requested a review from a team February 24, 2026 20:29
@mitesh-patel-crm mitesh-patel-crm requested a review from a team February 24, 2026 20:59
@mitesh-patel-crm mitesh-patel-crm merged commit add85e3 into develop Feb 24, 2026
42 checks passed
@mitesh-patel-crm mitesh-patel-crm deleted the mitesh-patel-crm/develop-shopper-consent-marketing-preferences-signed branch February 24, 2026 21:15
rasbhat pushed a commit that referenced this pull request Mar 5, 2026
…pper Consents hooks (#3674)

- Updated Email Subscription component (in the footer section) with Shopper Consents hooks, also with updated styling and labels.
- Updated commerce-sdk-react to use Shopper Consents hooks.
- Fix for email validation on marketing consent capture: TLD must be more than 1 character.
- Increase package max size from 90KB to 95KB, accounting for footer component size.
- Check for feature enablement via Shopper Configurations API (feature=>`EnableConsentWithMarketingCloud`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changelog Skip the "Changelog Check" GitHub Actions step even if the Changelog.md files are not updated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants